package org.big.rocktproducer.medium;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class TopicTestController {

    @Autowired
    private MessageServiceMedium messageService;

    @GetMapping("/send")
    public String sendMessage(@RequestParam String msg) {
        messageService.sendMessage(msg);
        return "Message sent: " + msg;
    }

    //    http://localhost:8080/send-order?orderId=ORD123&amount=99.99&status=PAID
    @GetMapping("/send-order")
    public String sendOrderMessage(
            @RequestParam String orderId,
            @RequestParam double amount,
            @RequestParam String status) {

        Order order = new Order(orderId,
                amount, status);
        messageService.sendOrderMessage(order);
        return "Order message sent: " + order;
    }
}